/*
 * All rights Reserved, Designed By www.goldbeacon.cn
 * @Title:  demo-springboot
 * @Package com.chenzhengrong.demospringboot.service.impl
 * @author: chenzhengrong
 * @date:   2022/8/17 12:42
 * @version V1.0
 * Copyright © 2022 www.goldbeacon.cn. All Rights Reserved.
 * 注意：本内容仅限于湖南金烽信息科技有限公司内部传阅，禁止外泄以及用于其他的商业目
 */
package com.chenzhengrong.demospringboot.service.impl;

import com.chenzhengrong.demospringboot.annotation.Log;
import com.chenzhengrong.demospringboot.domain.dto.RegionDTO;
import com.chenzhengrong.demospringboot.domain.pojo.Region;
import com.chenzhengrong.demospringboot.domain.vo.RegionVO;
import com.chenzhengrong.demospringboot.mapper.RegionMapper;
import com.chenzhengrong.demospringboot.service.RegionService;
import com.chenzhengrong.demospringboot.util.CustomerBeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chenzhengrong
 * @title: RegionServiceImpl
 * @description: 省市区数据服务接口层实现类
 * @date 2022/8/17 12:42
 */
@Service
public class RegionServiceImpl implements RegionService {

    @Autowired
    private RegionMapper regionMapper;

    /*
    * @description: 插入数据
    * @param regionDTO
    * @return int
    * @author chenzhengrong
    * @date 2022/8/18 9:47
    */
    @Override
    public int insert(RegionDTO regionDTO) {
        return regionMapper.insert(regionDTO);
    }

    /*
    * @description: 更新数据
    * @param regionDTO
    * @return int
    * @author chenzhengrong
    * @date 2022/8/18 9:44
    */
    @Override
    public int updateRegion(RegionDTO regionDTO) {
        return 0;
    }

    /*
    * @description: 根据名字查询地区数据
    * @param name
    * @return List<com.chenzhengrong.demospringboot.domain.dto.RegionDTO>
    * @author chenzhengrong
    * @date 2022/8/18 9:46
    */
    //@Log
    @Override
    public List<RegionDTO> findByName(String name) {
        List<Region> regions = regionMapper.findByName(name);
        return CustomerBeanUtils.copyListProperties(regions, RegionDTO::new);
    }

    /**
     * @param code 编号
     * @return cn.goldbeacon.demo.domain.entity.PCASCode
     * @description: 根据编号查询数据
     * @author zoujie
     * @date 2021/7/21 9:49
     */
    @Override
    public RegionDTO findByCode(String code) {
        Region region = regionMapper.findByCode(code);
        return CustomerBeanUtils.copyBeanProperties(region, RegionDTO::new);
    }
}
